<!DOCTYPE html>
<html>
<head>
    <include file="Include:meta"/>
    <title>项目款项统计-目的地运营集团数据管理平台</title>
    <include file="Include:style"/>
</head>
<body>
<include file="Include:header"/>
<include file="Include:left"/>
<div id="main">
    <div class="crumbs">
        <div class="crumbs-text">项目款项统计</div>
    </div>
    <div id="content">
        <div class="filter">
            <div class="filter-item">
                <div class="filter-title">项目类型：</div>
                <ul class="filter-order">
                    <li <if condition="$param['type'] eq null">class="current"</if>>
                        <a href="__APP__/ContractBack/payment_statistics/type/">全部</a>
                    </li>
                    <for start="1" end="6" comparison="elt">
                        <li <if condition="$param['type'] eq $i"> class="current"</if>>
                            <a href="__APP__/ContractBack/payment_statistics/type/{$i}">{:get_project_type($i)}</a>
                        </li>
                    </for>
                </ul>
            </div>
            <div class="filter-item">
                <div class="filter-title">开票状态：</div>
                <ul class="filter-order">
                    <li <if condition="$param['invoice_status'] eq null">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/invoice_status/">全部</a></li>
                    <li <if condition="$param['invoice_status'] eq 1">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/invoice_status/1">已开完</a></li>
                    <li <if condition="$param['invoice_status'] eq 2">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/invoice_status/2">未开完</a></li>
                </ul>
            </div>
            <div class="filter-item">
                <div class="filter-title">收款状态：</div>
                <ul class="filter-order">
                    <li <if condition="$param['back_status'] eq null">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/back_status/">全部</a></li>
                    <li <if condition="$param['back_status'] eq 1">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/back_status/1">已收</a></li>
                    <li <if condition="$param['back_status'] eq 2">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/back_status/2">未收</a></li>
                    <li <if condition="$param['back_status'] eq 3">class="current"</if>><a href="__APP__/ContractBack/payment_statistics/back_status/3">部分收</a></li>
                </ul>
            </div>
        </div>
        <div class="table-scrollx">
            <table class="table table-bordered table-hover">
                <tr class="table-header fixed-table-header">
                    <td width="">项目编号</td>
                    <td width="">项目名称</td>
                    <td width="">项目类型</td>
                    <td width="">合同金额</td>
                    <td width="">合同签订日期</td>
                    <td width="">已开票金额</td>
                    <td width="">剩余应开票金额</td>
                    <td width="">已收款金额</td>
                    <td width="">剩余应收款金额</td>
                </tr>
                <if condition="$result eq NULL">
                    <tr>
                        <td colspan="10" class="text-center">暂无相关内容</td>
                    </tr>
                </if>
                <foreach name="result" item="vo">
                    <tr>
                        <td><a class="xm_btn" href="javascript:;" contract_id="{$vo['contract_id']}">{$vo['project_num']}</a></td>
                        <td>{$vo['name']}</td>
                        <td>{:get_project_type($vo['type'])}</td>
                        <td>{:float_money($vo['contract_money'])}</td>
                        <td>{$vo['sign_contract_date']}</td>
                        <td><a class="kp_btn" href="javascript:;" contract_id="{$vo['contract_id']}"<if condition="$vo['make_money_sum'] lt $vo['contract_money']"> style="color:red"</if>>{:float_money($vo['make_money_sum'])}</a></td>
                        <td>{:float_money($vo['make_money_remain'])}</td>
                        <td><a class="sk_btn" href="javascript:;" contract_id="{$vo['contract_id']}"<if condition="$vo['money_sum'] lt $vo['make_money_sum']"> style="color:red"</if>>{:float_money($vo['money_sum'])}</a></td>
                        <td>{:float_money($vo['money_remain'])}</td>
                    </tr>
                </foreach>
                <if condition="$result neq NULL">
                    <tr>
                        <td colspan="3">合计</td>
                        <td>{:float_money($sum['contract_money_all'])}</td>
                        <td></td>
                        <td>{:float_money($sum['make_money_sum_all'])}</td>
                        <td>{:float_money($sum['make_money_remain_all'])}</td>
                        <td>{:float_money($sum['money_sum_all'])}</td>
                        <td>{:float_money($sum['money_remain_all'])}</td>
                    </tr>
                </if>
            </table>
        </div>
        <div class="pages">{$page}</div>
    </div>
</div>
<!--项目弹框-->
<div class="modal fade" id="xm-modal">
    <div class="modal-dialog w800">
        <div class="modal-content">
            <div class="modal-header">
                <h4>项目款项详情</h4>
                <i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
<!--开票弹框-->
<div class="modal fade" id="kp-modal">
    <div class="modal-dialog w1000">
        <div class="modal-content">
            <div class="modal-header">
                <h4>项目开票详情</h4>
                <i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
<!--收款弹框-->
<div class="modal fade" id="sk-modal">
    <div class="modal-dialog w1000">
        <div class="modal-content">
            <div class="modal-header">
                <h4>项目收款详情</h4>
                <i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
<div class="toolbar-annotation">
    <div class="annotation-title">功能注解</div>
    <ul class="annotation-item">
        <li>【已开票金额标红】已开票金额 < 合同金额</li>
        <li>【已收款金额标红】已收款金额 < 已开票金额</li>
    </ul>
</div>
<include file="Include:javascript"/>
<script type="text/javascript">
    $(function () {
        $('.xm_btn').click(function () {
            var contract_id = $(this).attr("contract_id");
            $.ajax({
                type: "GET",
                async: false,
                dataType: "json",
                data: {"contract_id": contract_id},
                url: "__APP__/ContractBack/getContractAndBack",
                success: function (data) {
                    if (data.stage){
                        $('#xm-modal').modal();
                        var html = "";
                        html += "<div class='form-main' style='border:none;margin-bottom:0'><div class='form-item'><div class='input-label'>合同编号</div><div class='input-item'>" + data.number + "</div></div><div class='form-item'><div class='input-label'>合同金额</div><div class='input-item'>" + data.contract_money + "</div></div><div class='form-item'><div class='input-label'>合同签订日期</div><div class='input-item'>" + data.sign_contract_date + "</div></div><div class='form-item'><div class='input-label'>合同附件</div><div class='input-item'>";
                        if (data.file_url) {
                            html += "" + data.file_name + "<a href='" + data.file_url + "' target='_blank' data-toggle='tooltip' data-placement='right' title='下载' class='ml5 download'><i class='glyphicon glyphicon-download-alt'></i></a>";
                        }
                        html += "</div></div><div class='form-item'><div class='input-label'>添加人(日期)</div><div class='input-item'>" + data.add_user + "(" + data.add_date.slice(0, 10) + ")</div></div><div class='form-sub-title'>款项阶段</div></div><div class='form-table-item'><table class='table stage_table'><tr class='form-table-header'><td>阶段</td><td>应收款金额</td><td>应收款日期</td><td>类型</td></tr>";
                        for (var i = 0; i < data.stage.length; i++) {
                            html += "<tr><td>└第" + data.stage[i].stage + "阶段</td><td>" + data.stage[i].stage_money + "</td><td>" + data.stage[i].stage_date + "</td><td>" + data.stage[i].type_name + "</td></tr>"
                        }
                        html += "</table></div>";
                        $('#xm-modal .modal-body').html(html);
                    } else {
                        defeated_alert('暂无款项阶段数据');
                    }
                }
            })
        })
        $('.kp_btn').click(function () {
            var contract_id = $(this).attr("contract_id");
            $.ajax({
                type: "GET",
                async: false,
                dataType: "json",
                data: {"contract_id": contract_id},
                url: "__APP__/ContractBack/getContractBackAndInvoice",
                success: function (data) {
                    if (data){
                        $('#kp-modal').modal();
                        var html = "<div class='form-table-item'><table class='table stage_table'><tr class='form-table-header'><td>款项阶段</td><td>该阶段应开票金额</td><td>该阶段已开票金额</td><td>开票记录</td><td>开票日期</td><td>发票编号</td><td>添加人(日期)</td></tr>";
                        for (var i = 0; i < data.length; i++) {
                            html += "<tr><td>└第" + data[i].stage + "阶段</td><td>" + data[i].stage_money + "</td><td>" + data[i].make_money_sum + "</td><td>" + data[i].make_money + "</td><td>" + data[i].make_date + "</td><td>" + data[i].number + "</td><td>" + data[i].add_user +"("+ data[i].add_date + ")</td>"
                            html +="</tr>"
                        }
                        html += "</table></div>";
                        $('#kp-modal .modal-body').html(html);
                    } else {
                        defeated_alert('暂无开票数据');
                    }
                }
            })
        })
        $('.sk_btn').click(function () {
            var contract_id = $(this).attr("contract_id");
            $.ajax({
                type: "GET",
                async: false,
                dataType: "json",
                data: {"contract_id": contract_id},
                url: "__APP__/ContractBack/getContractBackAndReceipt",
                success: function (data) {
                    if (data){
                        $('#sk-modal').modal();
                        var html = "<div class='form-table-item'><table class='table stage_table'><tr class='form-table-header'><td>款项阶段</td><td>该阶段应收款金额</td><td>该阶段已收款金额</td><td>收款记录</td><td>收款日期</td><td>添加人(日期)</td></tr>";
                        for (var i = 0; i < data.length; i++) {
                            html += "<tr><td>└第" + data[i].stage + "阶段</td><td>" + data[i].stage_money + "</td><td>" + data[i].money_sum + "</td><td>" + data[i].money + "</td><td>" + data[i].date + "</td><td>" + data[i].add_user +"("+ data[i].add_date + ")</td>"
                            html +="</tr>"
                        }
                        html += "</table></div>";
                        $('#sk-modal .modal-body').html(html);
                    } else {
                        defeated_alert('暂无收款数据');
                    }
                }
            })
        })
    });
</script>
</body>
</html>